package nku.csc360;
//Part 3 of the homework.

public class part3 {
	// Method that is originally called by code but not the working method. 
	// Method that readies for the working method. 
	public static void FindPaths2(int IkeStreet, int IkeAvenue, int homeStreet, int homeAvenue){
		FindPaths2("", IkeStreet, IkeAvenue, homeStreet, homeAvenue);
	}

	//Working method of part 3.
	public static void FindPaths2(String direction, int IkeStreet, int IkeAvenue, int homeStreet, int homeAvenue){
		//Variables declared to add or subtract from current position and direction to travel to
		//reach home.
		int lat = 0;
		char latchar = ' ';
		int lon = 0;
		char lonchar = ' ';
		
		//These next 2 Loop checks which direction to go to reach home.
		if(IkeStreet > homeStreet){
			lon = -1;
			lonchar = 's';}
		else if(IkeStreet < homeStreet){
			lon = +1;
			lonchar = 'n';}
		else if (IkeStreet == homeStreet){
			lon = 0;
			lonchar = ' ';}
		
		if(IkeAvenue > homeAvenue){
			lat = -1;
			latchar = 'w'; }
		else if(IkeAvenue < homeAvenue){
			lat = +1;
			latchar = 'e';}
		else if (IkeAvenue == homeAvenue){
			lat = 0;
			latchar = ' ';}
		
		//Base Case
		if(lon == 0 && lat == 0){
			System.out.println(direction);
		}
		//If only one direction to go.
		//Either west or east
		else if(lon == 0){
			FindPaths2(direction + latchar, IkeStreet, IkeAvenue + lat, homeStreet, homeAvenue);
		}
		//If only one direction to go.
		//Either north or south
		else if(lat == 0){
			FindPaths2(direction + lonchar, IkeStreet + lon, IkeAvenue, homeStreet, homeAvenue);
		}
		//if there is tow directions to go
		//either north or south and east or west.
		else{
			FindPaths2(direction + latchar, IkeStreet , IkeAvenue + lat, homeStreet, homeAvenue);
			FindPaths2(direction + lonchar, IkeStreet + lon, IkeAvenue, homeStreet, homeAvenue);
		}
	
	}
}
